{include file="common/header"}
<body class="pear-container">
<div class="layui-row layui-col-space15">
    <div class="layui-col-md12">
        <div class="layui-card">
            <form class="layui-form edit-form" method="post" action="">
                <div class="layui-tab layui-tab-brief" lay-filter="TabBrief">
                    <div class="layui-tab-content">
                        <div class="layui-form-item">
                            <label class="layui-form-label"><font color="red">*</font>收件人</label>
                            <div class="layui-input-block">
                                <input type="text" name="address" placeholder="英文逗号隔开" class="layui-input"
                                       lay-verify="required">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label"><font color="red">*</font>邮件标题</label>
                            <div class="layui-input-block">
                                <input type="text" name="title" placeholder="" class="layui-input"
                                       lay-verify="required">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label"><font color="red">*</font>邮件内容</label>
                            <div class="layui-input-block">
                                <textarea name="content" lay-verify="required" style="border-color: transparent;"
                                          id="notice_data"></textarea>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label"><font color="red"></font>邮件附件</label>
                            <div class="layui-input-block">
                                {Upfile:uploadFiletag tagid='file' name="file" url="[]" multiple="true" local="true"/}
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-input-block" style="min-height: 80px;">
                    <input type="hidden" id="__token__" name="__token__" value="{:token()}"/>
                    <button type="button" class="layui-btn layui-btn-normal layui-btn-sm" lay-submit=""
                            lay-filter="save">
                        <i class="layui-icon layui-icon-ok"></i>
                        提交
                    </button>
                    <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">
                        <i class="layui-icon layui-icon-refresh"></i>
                        重置
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>
{include file="common/footer"}
<script>
    layui.use(['form', 'jquery', 'tinymce', 'select', 'common'], function () {
        let form = layui.form;
        let $ = layui.jquery;
        let tinymce = layui.tinymce
        let common = layui.common;
        tinymce.render({
            elem: "#notice_data",
            images_upload_url: '{$Request.root}/index/upload?type=image',
            height: 600,
            convert_urls: false,
            setup: function (editor) {
                editor.on('blur', function () {
                    $("#notice_data").html(tinyMCE.activeEditor.getContent());
                })
            }
        });


        form.on('submit(save)', function (data) {
            $.ajax({
                data: JSON.stringify(data.field),
                dataType: 'json',
                contentType: 'application/json',
                type: 'post',
                success: function (res) {
                    if (res.code == 200) {
                        layer.msg(res.msg, {icon: 1, time: 1000}, function () {
                            window.location.reload();
                        });
                    } else {
                        layer.msg(res.msg, {icon: 2, time: 1000}, function () {
                            common.getToken();
                        });
                    }
                }
            })
            return false;
        });
    })
</script>
</body>
</html>